<?php
/**
 * Created by PhpStorm.
 * User: changyifan
 * Date: 2018/3/2
 * Time: 上午11:36
 */

namespace Home\Model;
use Think\Model\BaseModel;

class NaturalclassModel extends BaseModel{

    protected $_link =  array(
        'Profession' => array(
            'mapping_type' => self::BELONGS_TO,
            'class_name' => 'Profession',
            'foreign_key' => 'pro_id',
            'mapping_fields' => 'dept_id',
            'as_fields' => 'dept_id'
        ),
        'Department' => array(
            'mapping_type' => self::BELONGS_TO,
            'class_name' => 'Department',
            'foreign_key' => 'dept_id',
            'mapping_fields' => 'sch_id',
            'as_fields' => 'sch_id'
        ),
    );

    protected $_scope = array(
        'NcIdName' => array(
            'field' => array('cla_id','cla_name','pro_id'),
        )

    );

    public function getClassInfoListByAll(){
        $result = $this -> scope('NcIdName')->select();

        if($result){
            return $result;
        }else{
            return array();
        }
    }

    public function getNaturalInfoList($noun_id){
        if ($noun_id == 0) {
            $noun_id = array('like', "%%");
        }
        $info = $this -> scope('dataShow',array('where'=>array('pro_id'=>$noun_id)))->relation(true) -> select();
        if($info){
            return $info;
        }else{
            return array();
        }
    }



}